#include "support_common.h"
#include "pit0.h"
#include "pushb.h"
#include "intc.h"
//#include "uninhibit_all.h"
#include "gpio.h"
#include "intc.h"
#include "ledmat.h"
#include "qspi.h"
#include "dtim.h"
#include "i2c.h"
#include "n_chuck.h"

int all_flag = 1;

volatile int mode = 0;

int main(void)
{
	
	//uninhibit_all();
	//configure_interrupt(44, 1, 7, gpt_interrupt);
	//configure_interrupt(55, 4, 6, pit_interrupt);		
	pit0_init();
	gpt_init(); 
	qspi_init();
	ledmat_init();
	dtim0_init();
	i2c_init();
	n_chuck_init();
	
	

	while(1)
	{
		
		if (all_flag < 20)
		{
			if (mode == 0) 
			{
				ledmat_restart();
				ledmat_refresh();
			}
			else //if (mode == 1)
			{
		
					
			//ledmat_refresh();
			
			//if (all_flag<20)
				//{playgame(n_pattern);}
				
			
			
			//ledmat_restart();
			
			
			 playgame(n_pattern);
			 ledmat_refresh();
			}
				
			//}
		}
		else
		{ 
			
			//n_chuck_read ();
			for (int i=0; i<8; i++)
				{
					for (int j=0;j<8; j++)
					{	
						n_pattern[i][j] = next_pattern[i][j];
					}
				}
			all_flag=0;
			
		
		}
	}
}
